package as.dao;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import as.entity.Device;
    
public class DeviceDAO extends HibernateDaoSupport{
	public  boolean add(Device device  ){
		try{this.getHibernateTemplate().save(device);
		}catch(Exception e){
			e.printStackTrace();
			return false;
		}
		return true;
	}
	public  boolean update(Device device  ){
		try{this.getHibernateTemplate().update(device);
		}catch(Exception e){
			e.printStackTrace();
			return false;
		}
		return true;
	}
	public  Device get(int  id  ){
	return (Device)(this.getHibernateTemplate().get(Device.class, id));
		
	}
	public List<Device>  list(){
		return (List<Device>)(this.getHibernateTemplate().find("from Device"));			
		}
	public boolean delete(int id){
		Device device=new Device();
		device.setDeviceId(id);
		try{
			
			this.getHibernateTemplate().delete(device);
		}catch(Exception e){
			e.printStackTrace();
			return false;
		}
		return true;
		
	}

}
